﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.CodeDom;
using System.Reflection;
using System.ComponentModel;

namespace Conteinerid
{
    public delegate void AdviceExecution(object sender, AspectEventArgs args);

    public enum StateDirective { STATELESS, STATEFULL }

    [AttributeUsage(AttributeTargets.Constructor, Inherited = false, AllowMultiple = false)]
    public sealed class DefaultConstructorAttribute : Attribute
    {
        public DefaultConstructorAttribute() { }
    }

    [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
    public abstract class ContractDirective : Attribute {}

    [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
    public sealed class StateStrategyAttribute : ContractDirective
    {
        public StateDirective StateDirective { get; private set; }
        public StateStrategyAttribute(StateDirective stateDirective)
        {
            StateDirective = stateDirective;
        }
    }

    [AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
    public sealed class UserProvidedParameterAttribute : ContractDirective{}

    [AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
    public sealed class TransactionalMethodAttribute : ContractDirective {}

    public enum ToInvokeWhen
    {
        Entering,
        Leaving,
        Error
    }

    public class NamedParameter
    {
        public   Type  Type { get; set; }
        public string  Name { get; set; }
        public object Value { get; set; }
        public override string ToString()
        {
            return String.Format("{0}.{1}:{2}", Type.FullName, Name, Value??"<null>");
        }
    }

    public class AspectEventArgs : EventArgs
    {
        public string MethodName { get; set; }
        public IList<NamedParameter> Parameters { get; set; }
    }

    
}
